/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package vng.survey.controller;


import hapax.Template;
import hapax.TemplateDataDictionary;
import hapax.TemplateDictionary;
import java.io.IOException;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import vng.survey.model.CommonModel;
import vng.survey.model.RenderModel;

/**
 *
 * @author namhh
 */
public class NewSurveyController extends BaseController {

    @Override
    public String render(HttpServletRequest req, HttpServletResponse resp) throws IOException, Exception {
        String content = "";

        System.out.println(req.getRequestURL());

          System.out.println( "news: " + req.getRequestURL());

        TemplateDataDictionary dic = TemplateDictionary.create();
      
            dic.setVariable("HEADER", CommonModel.getHeader(TemplateDictionary.create(), "Tạo khảo sát mới"));
                    
          
            DateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy");

            Calendar cal = Calendar.getInstance();
            System.out.println(dateFormat.format(cal.getTime()));
            dic.setVariable("DATESTART", dateFormat.format(cal.getTime()));
            cal.add(Calendar.DATE, 7);
            dic.setVariable("DATEEND", dateFormat.format(cal.getTime()));
            dic.setVariable("FOOTER", CommonModel.getFooter(TemplateDictionary.create()));

            Template template = RenderModel.getCTemplate("newsurvey");
            content = template.renderToString(dic);
       
        return content;
    }

}
